<!DOCTYPE html>
<html lang="zh">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header :: header(~{::title},~{::link},~{})">
    <title>点餐</title>
    <link rel="icon" th:href="@{/assets/img/lcxm.ico}" type="image/ico">
</head>
<body class="body">
<!--导航-->
<div th:replace="common/nav :: nav(true)"></div>

<div class="container">

    <div class="row">
        <div style="margin-top: 20px;"></div>
        <div class="row">

            <form class="form-horizontal validate" role="form" method="post" th:action="@{/jira/save}"
                  onsubmit="return checkForm(this);">

                <!-- 操作信息提示的地方 -->
                <div th:if="${remind}" class="alert alert-${ remind.level  }"
                     th:classappend="'alert-' + ${remind.level}">
                    <button data-dismiss="alert" class="close" type="button">
                        <i class="glyphicon glyphicon-remove"></i>
                    </button>
                    <span th:remove="tag" th:utext="${ remind.message }"></span>
                </div>


                <div class="form-group">
                    <label for="code" class="col-md-1 col-sm-1 control-label">jira号</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="hidden" class="form-control" id="id" name="id" th:value="${entity?.id}"/>
                        <input type="text" class="form-control" id="code" name="code" th:value="${entity?.code}"
                               data-rule-required="true"
                               placeholder="jira号唯一" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="code" class="col-md-1 col-sm-1 control-label">父jira号</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="pcode" name="pcode" th:value="${entity?.pcode}"
                               data-rule-required="true"
                               placeholder="父jira号" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="projectId" class="col-md-1 col-sm-1 control-label">所属项目*</label>
                    <div class="col-sm-9  col-md-9  ">
                        <select class="form-control " id="projectId" name="projectId"
                                th:attr="data-value=${entity?.projectId}"
                                data-rule-required="true" data-url="project/all">
                            <option value="">--请选择项目--</option>
                        </select>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="settleYear" class="col-md-1 col-sm-1 control-label">结算年度</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="number" class="form-control" id="settleYear" name="settleYear"
                               th:value="${entity?.settleYear}" data-rule-required="true"
                               placeholder="结算年度" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="duration" class="col-md-1 col-sm-1 control-label">预计工时</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="number" class="form-control" id="duration" name="duration"
                               th:value="${entity?.duration}" data-rule-required="true"
                               placeholder="预计工时（分钟）" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="status" class="col-md-1 col-sm-1 control-label">状态</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="status" name="status" th:value="${entity?.status}"
                               data-rule-required="true"
                               placeholder="状态" autocomplete="off"/>

                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="type" class="col-md-1 col-sm-1 control-label">类型</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="type" name="type" th:value="${entity?.type}"
                               data-rule-required="true"
                               placeholder="类型" autocomplete="off"/>

                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="checkResult" class="col-md-1 col-sm-1 control-label">jira号检测</label>
                    <div class="col-sm-9  col-md-9  ">
                        <select class="form-control " id="checkResult" name="checkResult"
                                th:attr="data-value=${entity?.checkResult}" data-rule-required="true">
                            <option value="">--请修正jira号检测结果--</option>
                            <option th:each="item:${checkResults}" th:value="${item.name()}"
                                    th:text="${item.getText()}"></option>
                        </select>

                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="reporter" class="col-md-1 col-sm-1 control-label">报告人</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="reporter" name="reporter"
                               th:value="${entity?.reporter}" data-rule-required="true"
                               placeholder="报告人" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="assignee" class="col-md-1 col-sm-1 control-label">经办人</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="assignee" name="assignee"
                               th:value="${entity?.assignee}" data-rule-required="true"
                               placeholder="经办人" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="versionName" class="col-md-1 col-sm-1 control-label">修复版本</label>
                    <div class="col-sm-9  col-md-9  ">
                        <input type="text" class="form-control" id="versionName" name="versionName"
                               th:value="${entity?.versionName}" data-rule-required="true"
                               placeholder="修复版本" autocomplete="off"/>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <div class="form-group">
                    <label for="content" class="col-md-1 col-sm-1 control-label">jira内容</label>
                    <div class="col-sm-9  col-md-9  ">
                        <textarea class="form-control" id="content" name="content" data-rule-required="true"
                                  th:text="${entity?.content}"
                                  placeholder="jira内容" autocomplete="off" rows="5"></textarea>
                    </div>
                    <div class="col-md-2 col-sm-2  help-inline form-control-static"></div>
                </div>

                <hr/>

                <div class="form-group clearfix">
                    <div class="text-center col-sm-9">

                        <button th:if="${remind == null}" type="submit" class="btn btn-lg btn-primary">
                            <i class="glyphicon glyphicon-ok"></i> 提交
                        </button>

                        <a type="button" class="btn btn-lg  btn-info" th:href="@{/jira/}">
                            <i class="glyphicon glyphicon-repeat"></i> 返回
                        </a>
                    </div>
                </div>

            </form>
        </div>


    </div>
</div>

<!-- 引入通用js-->
<div th:replace="common/footer :: footer"></div>
<script>
    function checkForm(form) {
        var $form = $(form);
        var code = $("#code").val();
        var projectId = $("#projectId").val();
        var duration = $("#duration").val();
        var content = $("#content").val();
        var check = true;
        if (code && projectId && content && duration) {
            //校验jira号
            $.ajax({
                async: false,
                url: ctx + 'jira/checkCode',
                type: 'post',
                data: {
                    code: code,
                    id: $("#id").val()
                },
                success: function (data) {
                    check = data.data;
                    if (!check) {
                        $.alert({
                            theme: 'bootstrap',
                            title: '温馨提示',
                            content: "jira号已存在"
                        });
                    }
                }
            });
            if (check) {
                return check;
            }

        }

        $.alert({
            theme: 'bootstrap',
            title: '温馨提示',
            content: '请完整填写jira内容'
        });

        return false;
    };


</script>

</body>
</html>